package com.lk.springboot.dao;

import com.lk.springboot.vo.ScruIdAndType;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lk
 * @date 2020/1/20 0020 18:27
 */
@Mapper
public interface ScheduleMapper {

    // 清空表中数据
    @Delete("delete from user_token ")
    void clearToken();

    // 将所有用户的完成任务进度置为 0
    @Update("update u_t_solve set speed = 0")
    void resetUserTaskSpeed();

    // 将所有的用户的魔法市场的次数，清 0
    @Update("update users set market_times = 0 ")
    void resetMarketNum();

    // 将所有用户的魔法市场购买的拼图的记录，清零
    @Update("update user_scoreru_magic set isbought = 0 ")
    void resetIsBought();

    // 获取积分兑换表中的每条记录
    @Select("select scru_id,ru_type from score_ru ")
    ArrayList<ScruIdAndType> getScoreRu();

    // 更新积分兑换表中的拼图id，sp_id
    @Update("update score_ru set sp_id=#{sp_id} where scru_id=#{scru_id}")
    void updateScoreRuSP(@Param("scru_id") String scru_id, @Param("sp_id") String sp_id);

    // 获取sp_id
    @Select("select photo.sp_id from photo,smallphoto where  p_id = #{p_id} and rare=#{rare} and tags < 10 and photo.sp_id=smallphoto.sp_id")
    String getSPList(@Param("p_id") String p_id, @Param("rare") String rare);

    //------------------------------里程任务-----------------------------------
    // 每天将今日里程数清零
    @Update("update users set today_mileage = 0 ")
    void resetTodayMileage();

    // 将每一个单次里程加入今日里程总数
    @Update("update users set today_mileage = today_mileage + #{mileage} where u_id = #{u_id}")
    void addTodayMileage(@Param("u_id") String u_id,@Param("mileage") int mileage);

    // 获取今日里程总数
    @Select("select today_mileage from users where u_id = #{u_id}")
    int getTodayMileage(String u_id);

    // 将每日单次里程计入总里程中
    @Update("update users set total_mileage = total_mileage + #{mileage} where u_id = #{u_id}")
    void addTotalMileage(@Param("u_id") String u_id,@Param("mileage") int mileage);

    // 里程任务达到进度要求,进度置为1
    @Update("update  u_t_solve set speed=1 where u_id=#{u_id} and t_id='t10007' and speed < 999 ")
    void signMileage(String u_id);

    // 乘地铁任务达到进度要求，进度置为1
    @Update("update  u_t_solve set speed=1 where u_id=#{u_id} and t_id='t10006' and speed < 999 ")
    void signBySubway(String u_id);

    // 获取用户表中所有用户的id
    @Select("select u_id from users")
    ArrayList<String> getAllUserId();

    //将所有用户的magic_status
    @Update("update users set magic_status = 0 ")
    void resetMagicStatus();

}
